import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { User } from '../../../model/User';
import { PageInfo } from '../../../model/Page';
import { UserService } from '../../../service/user.service';

@Component({ 
    templateUrl: 'user-add.component.html',
})
export class UserAddComponent {

   active: boolean = true;

   user = new User();
    
    get userInfo() {
        return JSON.stringify(this.user);
    }

    constructor(private router:Router,private  _userService:UserService ) { }

    submitForm() {
        alert(this.userInfo + '已经被提交!');
         this._userService
                .addUser(this.user).then(()=>this.router.navigate(['user/list']))
               
                } 
    cleanForm(){
        this.active = false;
        this.user=new User ;
        setTimeout(() => this.active = true, 0);
    }



}